<html>
<head><meta charset="utf-8"><title>workaround for known improperly reduced borrows · t-compiler/wg-polonius · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/index.html">t-compiler/wg-polonius</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/workaround.20for.20known.20improperly.20reduced.20borrows.html">workaround for known improperly reduced borrows</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="203651208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/workaround%20for%20known%20improperly%20reduced%20borrows/near/203651208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wodann <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/workaround.20for.20known.20improperly.20reduced.20borrows.html#203651208">(Jul 12 2020 at 16:53)</a>:</h4>
<p>If I understand correctly, Polonius is aimed at resolving several known issues with the Rust lifetimes, such as those listed here: <a href="https://doc.rust-lang.org/nomicon/lifetime-mismatch.html#improperly-reduced-borrows">https://doc.rust-lang.org/nomicon/lifetime-mismatch.html#improperly-reduced-borrows</a> . As Polonius is currently only available on nightly, I was wondering whether there are any available resources for overcoming these lifetime issues - be it with safe or <code>unsafe</code> code - on stable? I am particularly interested in the <code>match</code> use case, but I think it would be useful overall.</p>



<a name="203653431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/workaround%20for%20known%20improperly%20reduced%20borrows/near/203653431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/workaround.20for.20known.20improperly.20reduced.20borrows.html#203653431">(Jul 12 2020 at 17:46)</a>:</h4>
<p>AFAIK, all lifetime issues can we worked-around using unsafe code. You "just" convert all the lifetimes to <code>'static</code> (and optionally convert it back to something appropriate). Hopefully it's obvious why this is rarely used.</p>



<a name="203653449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/workaround%20for%20known%20improperly%20reduced%20borrows/near/203653449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/workaround.20for.20known.20improperly.20reduced.20borrows.html#203653449">(Jul 12 2020 at 17:47)</a>:</h4>
<p>See also <a href="https://stackoverflow.com/q/38023871/155423">Returning a reference from a HashMap or Vec causes a borrow to last beyond the scope it's in?</a></p>



<a name="203926032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/workaround%20for%20known%20improperly%20reduced%20borrows/near/203926032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wodann <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/workaround.20for.20known.20improperly.20reduced.20borrows.html#203926032">(Jul 15 2020 at 08:00)</a>:</h4>
<p>Thanks. I was afraid that was the only solution.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>